package router

import (
	"go_final/mxshop_api/goods_web/api/goods"
	middlewares "go_final/mxshop_api/goods_web/middleware"

	"github.com/gin-gonic/gin"
)

func InitGoodsRouter(Router *gin.RouterGroup) {
	GoodsRouter := Router.Group("goods")

	{
		GoodsRouter.GET("", goods.List)
		GoodsRouter.POST("", middlewares.JWTAuth(), middlewares.IsAdmin(), goods.New) // 该接口需要管理员权限
		GoodsRouter.GET("/:id", goods.Detail)
		GoodsRouter.DELETE("/:id", middlewares.JWTAuth(), middlewares.IsAdmin(), goods.Delete)
		GoodsRouter.GET("/:id/stocks", goods.Stocks) //获取商品的库存
		GoodsRouter.PUT("/:id", middlewares.JWTAuth(), middlewares.IsAdmin(), goods.Update)
		GoodsRouter.PATCH("/:id", middlewares.JWTAuth(), middlewares.IsAdmin(), goods.UpdateStatus)
	}
}
